FINAL PROJECT GAME: JUMP RUSH


Hello and welcome back. So in today's tutorial, were 
creating a Game that includes all the features in our previous blogs and compile them to this one specific game, were adding a Main Menu Scene, Level Select Scene, and the Levels of the game itself. If you are following our game dev journey, maybe you should check out our previous blog that we made.

Previous Blog: Level Unlock


JUMP RUSH

Developed by: John Ray Vino
Concept By: Jen Carlo Napoto
Authored by: Niko Panizales


So without further ado, let's begin!

This time, were combining two features in one game. A Main Menu scene and Level Select Scene with levels included. By this, I added the assets from Act 7 and 8 in the Project Tab/Assets. Place them as is. To add assets from different Projects, just open File Manager/Documents/Adobe then find the specific assets from any projects you want to export in. Just drag and drop those files in our Projects tab.



Assembling the scenes are just easy. On your Build setting, the arrangement must be MainMenu Scene,Level Select Scene, Level1, Level2, Level3, Level etc. You can change the sprites and how the scene looks by adding new sprites. For now, leave it like that in the arrangement. 



Now we have to change some scripts for the Level Controller Scripts youWin() method. We changed the sceneIndex to 4 based of the maxed Build setting number of the game.

You may copy this part of the script then apply it to your level controller script. To get the full script, get it to the previous blog Level Unlock.


public void youWin()

    {

        if (sceneIndex == 4)

            Invoke ("loadMainMenu", 1f);

        else

        {

            if (levelPassed < sceneIndex)

                PlayerPrefs.SetInt("LevelPassed", sceneIndex);

            levelSign.gameObject.SetActive(false);

            youWinText.gameObject.SetActive(true);

            Invoke ("loadNextLevel", 1f);

        }

    }

Now that you had placed this to our script. Then we had to also change the Main Menu Controller script in our Level Select Scene. So that it will load the next scene appropriately.

Apply this to your Main Menus Controller script.


void Start()

{

        levelPassed = PlayerPrefs.GetInt("LevelPassed");

        level02Button.interactable = false;

        level03Button.interactable = false;


        switch(levelPassed)

        {

            case 1:

                level02Button.interactable = true;

                break;

            case 2:

                level02Button.interactable = true;

                level03Button.interactable = false;

                break;

            case 3:

                level02Button.interactable = true;

                level03Button.interactable = true;

                break;

        }

    }

Now it should function well. If not, try resolving some compiler issues to fix it.

Let's move on to making the game, using some of the sprites from the previous game that I made which is named Ball Rush. We used the sprites so that it wont be time consuming to make, well we just changed mostly the arrangement of obstacles and level that has a different color and difficulty. Still we used the skull script from the previous blog to act as an enemy onces placed to our enemy obejct, but I din't put a Move script for it because I find it difficult to play for our player to avoid. For now I just placed them adjacent to the difficult parts of the levels





But this games player movement is different. We decided to make a Jump mechanics game, like a game that resembles the movements in Mario. This player can only move left to right and jump using the space bar. Like a typical Mario game which is easy to make. So I founded a script that only allows the player to move like in Mario.

Here's the script. 

Move2D Script:


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Move2D : MonoBehaviour {

    private Rigidbody2D rb2D;

    public float moveSpeed = 5f;

    public bool isGrounded = false;


    void Start(){

        

    }

   

    void Update() {

        Jump();

        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);

        transform.position += movement * Time.deltaTime * moveSpeed;

    }


    void Jump(){

        if (Input.GetButtonDown("Jump") && isGrounded == true){

            gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 200000f), ForceMode2D.Impulse);

        }

    }

}

Apply this to our player. Also add a rigidbody2D and collider to our player. Assign a mass and gravity to our rigidbody, then adjust it until it matches the specific movement we want. On the script, we can also change the force of our jump. Next script is for the player be grounded once it hit the platform where should the player be landing on. By that we added another gameObject under player named "GroundCheck" which this script will read as is. Apply a collider to our grounded object and place it inside the player.



Here's the grounded script:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Grounded : MonoBehaviour{

    GameObject Player;

    // Start is called before the first frame update

    void Start(){

        Player = gameObject.transform.parent.gameObject;

    }


    // Update is called once per frame

    void Update(){

        

    }


    private void OnCollisionEnter2D(Collision2D collision)

    {

        if (collision.collider.tag == "Ground"){

            Player.GetComponent<Move2D>().isGrounded = true;

        }

    }


    private void OnCollisionExit2D(Collision2D collision)

    {

        if (collision.collider.tag == "Ground"){

            Player.GetComponent<Move2D>().isGrounded = false;

        }

    }

}


By that, the player can jump to our game and be played like how we play some of the well known games that we have. Now it's up to your from this point to add more into the game. Like sound effects, animation, enemy movements and mechanics. Hope that this blog helped you in making your game.

WATCH VIDEO BELOW



Comments

Popular Posts